
import React from 'react'
import { Navigate, useRoutes } from 'react-router-dom'

// function generateRouter( routers ) {
//   return routers.map( ( item ) => {
//     const obj = { ...item }
//     const { children, redirect, component } = item
//     if ( children && children.length ) {
//       obj.children = generateRouter( children )
//     }

//     let element
//     if ( component ) {
//       element = <item.component />
//     } else {
//       if ( redirect ) {
//         element = <Navigate to={item.redirect} replace />
//       }
//     }
//     obj.element = element
//     return obj
//   } )
// }

const DynamicRouter = ( props ) => {
  const element = props.routes
  console.log(element, 'routeList');
  return useRoutes(element)
}

export default DynamicRouter
